home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
LIFE6__
/
PROTO
/
P
/
PUTILS_L.C
< prev
next >
Wrap
Text File
|
1991-08-16
|
5KB
|
141 lines
/* PUtils_Life6 Utilities
File name: PUtils_Life6.C
Function: Utilities for the Prototyper specific code.
History: 8/16/91 Original by Prototyper 3.0 */
#include "PCommonLife6.h" /* Common */
#include "Common_Life6.h" /* Common */
#include "PUtils_Life6.h" /* This file */
/* ======================================================= */
/* Routine: TrapAvailable */
/* Purpose: See if trap is available, non-available traps all have a unique address */
Boolean TrapAvailable (trapNumber,tType) /* See if a trap is available */
short trapNumber;
short tType;
{
#define UnimplementedTrapNumber 0xA89F /* Unimplemented trap number */
Boolean theResult;
theResult = (NGetTrapAddress(trapNumber, tType) != GetTrapAddress(UnimplementedTrapNumber));/* Check the two traps */
return(theResult);
}
/* ======================================================= */
/* Routine: GetUserEvent */
/* Purpose: See if any user events are available */
void GetUserEvent(UserEventPRec TheUserEvent)
{
UserEventHRec NextUserEvent; /* The next user event */
TheUserEvent->ID = UserEvent_None; /* Set ID to no events are available */
if (UserEventList != NIL) /* Get first entry in the list */
{
HLock((Handle)UserEventList); /* Lock for safety */
TheUserEvent->ID = (*UserEventList)->ID; /* The event ID */
TheUserEvent->ID2 = (*UserEventList)->ID2; /* The optional ID */
TheUserEvent->Data1 = (*UserEventList)->Data1;/* The optional data */
TheUserEvent->Data2 = (*UserEventList)->Data2;/* The optional data */
TheUserEvent->theHandle = (*UserEventList)->theHandle;/* The optional handle */
NextUserEvent = (*UserEventList)->Next; /* The next list */
DisposHandle((Handle)UserEventList); /* Remove this list item */
UserEventList = NextUserEvent; /* Make the next item the new first item */
}
}
/* ======================================================= */
/* Routine: Add_UserEvent */
/* Purpose: Add a user event */
void Add_UserEvent( ID, ID2, Data1, Data2, theHandle)
short ID;
short ID2;
long Data1;
long Data2;
Handle theHandle;
{
UserEventHRec NewUserEvent; /* The new user event */
UserEventHRec theUserEvent; /* The user event */
NewUserEvent = (UserEventHRec)NewHandle(sizeof(UserEventRec));/* Allocate a record */
if (NewUserEvent != NIL) /* Only do if we got the new record */
{
HLock((Handle)NewUserEvent); /* Lock for safety */
(*NewUserEvent)->ID = ID; /* The event ID */
(*NewUserEvent)->ID2 = ID2; /* The optional ID */
(*NewUserEvent)->Data1 = Data1; /* The optional data */
(*NewUserEvent)->Data2 = Data2; /* The optional data */
(*NewUserEvent)->theHandle = theHandle; /* The optional handle */
(*NewUserEvent)->Next = NIL; /* No next item after this one */
if (UserEventList == NIL) /* See if anyone is in the list yet */
UserEventList = NewUserEvent; /* Make this one the first in the list */
else /* Not the first in the list */
{
theUserEvent = UserEventList; /* Get the first one */
while ((*theUserEvent)->Next != NIL) /* Get the next one */
{
theUserEvent = (*theUserEvent)->Next;
}
(*theUserEvent)->Next = NewUserEvent; /* Tack on to the end */
}
}
}
/* ======================================================= */
/* Setup a dialog or alert item */
void SetupTheItem( theDialog, ItemID, SizeIt, ShowIt,EnableIt,SetTheMax,thePosition, ExtraData, StringID)
DialogPtr theDialog;
short ItemID;
Boolean SizeIt;
Boolean ShowIt;
Boolean EnableIt;
Boolean SetTheMax;
Rect *thePosition;
long ExtraData;
short StringID;
{
Rect tempRect; /* Temporary rectangle */
short DType; /* Type of dialog item */
Handle DItem; /* Handle to the dialog item */
ControlHandle CItem; /* Control handle */
GetDItem(theDialog,ItemID,&DType,&DItem,&tempRect);/* Get the item handle and size */
CItem = (ControlHandle)DItem; /* Change to control handle */
if (SizeIt) /* Have to resize all CDEF connected controls */
SizeControl(CItem, tempRect.right-tempRect.left, tempRect.bottom-tempRect.top);/* Size it */
*thePosition = tempRect; /* Pass back the zone location and size */
if (ExtraData != NIL) /* See if extra data for a CDEF */
(*CItem)->contrlData = (Handle)ExtraData; /* Send it */
if (StringID != 0) /* See if a CDEF and needs the title set again*/
{
GetIndString(sTemp,StringID,1); /* Get the string */
SetCTitle(CItem,sTemp); /* Set the string */
}
if (EnableIt) /* See if enable or disable the zone */
HiliteControl (CItem,0); /* Enable the zone */
else
HiliteControl (CItem,255); /* Dim the zone */
if (SetTheMax)
SetCtlMax(CItem,12345); /* Set the flag to the CDEF */
if (ShowIt)
ShowControl(CItem); /* Show it to activate it */
}
/* ======================================================= */